// Last Update:2015-01-28 14:08:07
/**
 * @file hx_irand.c
 * @brief 
 * @author 
 * @version 0.1.00
 * @date 2015-01-28
 */

#include <stdio.h>
#include <stdlib.h>

#include <signal.h>
#include <unistd.h>

#include <libHX/misc.h>

static int a[11];

void sigint_handler(int signum)
{
	int i;
	printf("Accurred Counter: \n");
	for (i = 1; i < 11; i++)
	{
		printf("%d: %d\n", i, a[i]);
	}
	printf("\n");
	exit(EXIT_SUCCESS);
}

int main(int argc, char *argv[])
{
	signal(SIGINT, sigint_handler);
	while (1)
	{
		unsigned int i = HX_irand(1, 100000);
		fflush(stdout);
		switch (i)
		{
			case 1:
				a[1]++;
				break;
			case 2:
				a[2]++;
				break;
			case 3:
				a[3]++;
				break;
			case 4:
				a[4]++;
				break;
			case 5:
				a[5]++;
				break;
			case 6:
				a[6]++;
				break;
			case 7:
				a[7]++;
				break;
			case 8:
				a[8]++;
				break;
			case 9:
				a[9]++;
				break;
			case 10:
				a[10]++;
				break;
		}
	}
	
	return 0;
}
